﻿using Library.Core.Domain.Aggregation;
using Library.Core.Domain.Jwt;
using System;
using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt;
using System.Text;
using System.Threading.Tasks;

namespace Library.Core.Application.IInfrastructure
{
    public interface IJwtFactory
    {
        public JwtSecurityToken Token { get; set; }

        /// <summary>
        /// 生成Token
        /// </summary>
        /// <param name="userLoginInfo"></param>
        /// <returns></returns>
        Task<JwtLoginInfo> GenerateTokenAsync(JwtUserInfo userLoginInfo);

        /// <summary>
        /// 检查刷新token的有效性
        /// </summary>
        /// <param name="refreshtoken"></param>
        /// <param name="accessToken"></param>
        /// <returns></returns>
        Task<JwtSecurityToken> CheckRefreshTokenAsync(string refreshtoken, string accessToken);

        /// <summary>
        /// 验证token有效性
        /// </summary>
        /// <param name="token"></param>
        /// <returns></returns>
        Task<bool> TokenIsInInvalid(JwtSecurityToken? token);

        /// <summary>
        /// 加入黑名单
        /// </summary>
        /// <param name="token"></param>
        /// <returns></returns>
        Task AddTokenToBlackList(JwtSecurityToken token);

        /// <summary>
        /// 删除授权中对应用户信息
        /// </summary>
        /// <param name="userNameList"></param>
        /// <returns></returns>
        Task MakeUserAllTokenInvalid(List<string> userNameList);

    }
}
